import entity.Book;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author：xz
 * @Date：2023/7/17
 */
public class ListTest {
    public static void main(String[] args) {
        test4();
    }

    private static void test1(){
        List<BigDecimal> accountIdList = new ArrayList<>();
//        accountIdList.add(new BigDecimal(100.06));
//        accountIdList.add(new BigDecimal(125250.55));
        BigDecimal bigDecimal = accountIdList.stream().reduce(BigDecimal::add).orElse(BigDecimal.ZERO).setScale(2,BigDecimal.ROUND_HALF_UP);
        System.out.println(bigDecimal);
    }

    private static void test2(){
        List<Long> list = new ArrayList<>();
        list.add(null);
        list.add(null);
//        list.add(1L);
        System.out.println(list.size());
        System.out.println(list.isEmpty());
        List<Long> collect = list.stream().filter(Objects::nonNull).collect(Collectors.toList());
        System.out.println(collect.size());
        System.out.println(collect.isEmpty());
    }

    private static void test3(){
        List<Book> list = new ArrayList<>();
        list.add(new Book(1L,null,"23",99,new BigDecimal(2),"345"));
        Map<Long, String> collect = list.stream().collect(Collectors.toMap(Book::getId, Book::getName));
        System.out.println(list);
    }

    private static void test4(){
        List<Integer> list = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list2.add(2);
        list2.add(3);
        list2.add(4);
        List<Integer> collect = list.stream().filter(l -> !list2.contains(l)).collect(Collectors.toList());
        System.out.println(collect);
    }
}
